package string_;

/**
 * Created with IntelliJ IDEA.
 * ClassName: TestStirng
 * Package: string_
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-29
 * Time: 20:08
 */

public class TestString {

    public static void main(String[] args) {


        //直接在字符串常量池中创建了hello
        String s1 = "hello";
        String s2 = "hello";

        //内存解析 常见问题这样的方式创建了几个对象
        String s3 = new String("hello");
        String s4 = new String("hello");

        System.out.println(s1 == s2); //true
        System.out.println(s1 == s3); //false
        System.out.println(s1 == s4); //false
        System.out.println(s3 == s4); //false

        System.out.println(s1.equals(s2)); //true


    }

}
